package com.jiejie.controller;


import com.jiejie.service.ICouponService;
import com.jiejie.service.IMovieService;
import com.jiejie.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 辰广
 * @since 2022-10-05
 */
@RestController

public class OrderController {
    @Autowired
    private IOrderService iOrderService;
    @Autowired
    private IMovieService iMovieService;
    @Autowired
    private ICouponService iCouponService;

    @GetMapping("order")
    public ModelAndView getOrderAndSchedule(@RequestParam("customerId") Integer customerId) {
        System.out.println("获得用户id:"+customerId);
        ModelAndView modelAndView = new ModelAndView();
        //数据绑定
        modelAndView.addObject("OrderAndSchedule", iOrderService.getOrderAndSchedule(customerId));
        modelAndView.addObject("OrderAndMovie",iMovieService.getOrderMovie(customerId));
        modelAndView.addObject("CustomerCoupon",iCouponService.getCoupon(customerId));
        //页面跳转
        modelAndView.setViewName("pages/profile_order");
        System.out.println("ssds:"+iOrderService.getOrderAndSchedule(customerId));
        return modelAndView;
    }
}
